package com.oscarmovie;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5 {
public static void main(String[] args) {
	String plainText = "http://img21.mtime.cn/mt/2010/08/31/123107.67747634.jpg";
	
	MessageDigest md;
	try {
		
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");  
        
//        System.out.println("MD5????-----" + HexUtils.bytesToHexString(messageDigest.digest(plainText.getBytes())));  
        Integer zz = 17;
        
        System.out.println("MD5.main(): "+bytesToHexString(messageDigest.digest(plainText.getBytes())));
	} catch (NoSuchAlgorithmException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	
}

	public static String bytesToHexString(byte[] src) {  
        StringBuilder stringBuilder = new StringBuilder("");  
        if (src == null || src.length <= 0) {  
            return null;  
        }  
        for (int i = 0; i < src.length; i++) {  
            int v = src[i] & 0xFF;  
            String hv = Integer.toHexString(v);  
            if (hv.length() < 2) {  
                stringBuilder.append(0);  
            }  
            stringBuilder.append(hv);  
        }  
        return stringBuilder.toString();  
    }  
}
